//index.js
const app = getApp()
Page({
  data: {
    weather: [],
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    Custom: app.globalData.Custom,
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    TabCur: 1,
    scrollLeft: 0,
    ProvinceList: [{
      title: '安徽',
      name: 'red',
      color: '#e54d42'
    },
    {
      title: '浙江',
      name: 'orange',
      color: '#f37b1d'
    },
    {
      title: '江苏',
      name: 'yellow',
      color: '#fbbd08'
    },
    {
      title: '内蒙古',
      name: 'olive',
      color: '#8dc63f'
    },
    {
      title: '青海',
      name: 'green',
      color: '#39b54a'
    },
    {
      title: '江西',
      name: 'cyan',
      color: '#1cbbb4'
    },
    {
      title: '河北',
      name: 'blue',
      color: '#0081ff'
    },
    {
      title: '山东',
      name: 'purple',
      color: '#6739b6'
    },
    {
      title: '甘肃',
      name: 'mauve',
      color: '#9c26b0'
    },
    {
      title: '陕西',
      name: 'pink',
      color: '#e03997'
    },
    {
      title: '山西',
      name: 'brown',
      color: '#a5673f'
    },
    {
      title: '贵州',
      name: 'grey',
      color: '#8799a3'
    },
    {
      title: '上海',
      name: 'gray',
      color: '#aaaaaa'
    },
    {
      title: '北京',
      name: 'black',
      color: '#333333'
    },
    {
      title: '黑龙江',
      name: 'white',
      color: '#ffffff'
    },
    ]
  },
  onLoad: function () {
    this.getUserLocation()
  },
  getUserLocation: function(e) {
    var that = this
    wx.getLocation({
      type: 'gcj02', //返回可以用于wx.openLocation的经纬度
      success: function (res) {
        var latitude = res.latitude//维度
        var longitude = res.longitude//经度
        console.log(res)
        // wx.openLocation({
        //   latitude,
        //   longitude,
        //   scale: 18
        // })
      }
    })
  },
  showModal(e) {
    this.setData({
      modalName: e.currentTarget.dataset.target
    })
  },
  hideModal(e) {
    this.setData({
      modalName: null
    })
  },
  tabSelect(e) {
    console.log(e);
    this.setData({
      TabCur: e.currentTarget.dataset.id,
      scrollLeft: (e.currentTarget.dataset.id - 1) * 60
    })
  },
  goToDetail: function () {
    wx.navigateTo({
      url: '/pages/detail/detail',
    })
  }
})
